//
//  GSRootViewController.m
//  GameSky
//
//  Created by lanou on 16/1/9.
//  Copyright © 2016年 NiRongfei. All rights reserved.
//

#import "GSRootViewController.h"
#import "GSRootTabBarController.h"

@interface GSRootViewController () <UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) GSRootTabBarController *rootTBC;

@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, strong) NSArray *dataArray;

@end

@implementation GSRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addSubviews];
    
    // 添加标签控制器视图;
    self.rootTBC = [[GSRootTabBarController alloc] init];
    [self.view addSubview:self.rootTBC.view];
}

- (void)addSubviews {
    // 1.添加TableView;
    self.dataArray = @[@"搜索",@"要闻",@"收藏",@"清空缓存",@"夜间模式",@"3G/4G无图",@"我要反馈",@"更多设置"];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 220, kScreenWidth * 0.7, kScreenHeight - 150) style:(UITableViewStylePlain)];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.rowHeight = (kScreenHeight - 220) / self.dataArray.count;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"RootCell"];
    [self.view addSubview:self.tableView];
    
    // 2.添加表头
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, kScreenWidth * 0.7, 200)];
    headerView.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:headerView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RootCell" forIndexPath:indexPath];
    cell.textLabel.text = self.dataArray[indexPath.row];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
